﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.ComponentModel;
using System.Windows;
using System.Windows.Forms;

namespace CrusadeGmTool.ComponentModel
{
    public abstract class NotifierBase
    {


        /// <summary>
        /// Raises the PropertyChanged event for each property.
        /// </summary>
        /// <param name="propertyNames"></param>
        protected void RaisePropertyChanged(params string[] propertyNames)
        {
            for (int i = 0; i < propertyNames.Length; i++)
            {
                OnPropertyChanged(this, new PropertyChangedEventArgs(propertyNames[i]));
            }
        }

        /// <summary>
        /// Notifies of a property value change within the object.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Called when a property changes.
        /// </summary>
        /// <param name="sender">The object whose property changed</param>
        /// <param name="e">The PropertyChangedEventArgs containing information of the property that changed.</param>
        protected virtual void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(sender, e);
            }
        }
    }
}
